package br.com.evento.view.converter;

import java.io.Serializable;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 * Classe que converte um boolean em uma string definida e vice-versa
 * 
 * @author Rafael Trassi
 */
@FacesConverter("booleanConverter")
public class BooleanConverter implements Converter, Serializable {

	private static final long serialVersionUID = 1L;

	@Override
	public Object getAsObject(FacesContext ctx, UIComponent component, String value) {
		return value.equals("X") ? true : false;
	}

	@Override
	public String getAsString(FacesContext ctx, UIComponent component, Object value) {
		return ((Boolean)(value)) ? "X" : "" ;
	}

}
